﻿using Dapper;
using Domain.Entity.zct;
using Domain.IRepository;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore.Repository
{
    public class RolePermissionRepository : IRolePermissionRepository
    {
        //连接字符串
        string con = "Data Source=121.37.93.71;Initial Catalog=CSSL_ZCTWMS;User ID=sa;Password=geili@2025;Encrypt=False";

        public async Task<List<RolePermission>> Getpid(int pid)
        {
            using (SqlConnection sqlConnection = new SqlConnection(con))
            {
                await sqlConnection.OpenAsync();
                string sql = @$"select Role_permission_id,Role_id,Permission_id from [dbo].[zct_role_permission] where role_id=@pid";

                var parameters = new DynamicParameters();
                parameters.Add("@pid", pid);

                List<RolePermission> rolePermissions = sqlConnection.Query<RolePermission>(sql, parameters).ToList();
                return rolePermissions;
            }
        }
    }
}
